# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>

pkgname=libvirt-dbus
pkgver=1.4.1
pkgrel=2
pkgdesc="Wrapper around libvirt API to provide a high-level object-oriented API better suited for dbus-based applications"
arch=('loong64' 'x86_64')
url="https://libvirt.org/dbus.html"
license=('LGPL')
depends=('libvirt-glib' 'dbus' 'libssh')
makedepends=('meson' 'ninja' 'python-docutils')
options=('debug')
validpgpkeys=('4252D86A52041137C291CADFC85C5E957062A701')
source=("https://libvirt.org/sources/dbus/${pkgname}-${pkgver}.tar.xz"{,.asc})
sha512sums=('8215df988ae5c60a179c8be2f181f2c0c64b23e20e0575110ee64a0e60fd03e1523ac27a854192990cd94c76b3b771358e350d7c1bceccb9c05e9e0bf9143563'
            'SKIP')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  meson build \
    --prefix=/usr \
    --sbindir=/usr/bin \
    --sysconfdir=/etc \
    --localstatedir=/var
  ninja -C build
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}/build"
  DESTDIR="$pkgdir" ninja install

  chmod 750 "${pkgdir}/usr/share/polkit-1/rules.d"

  install -dm0755 "${pkgdir}/usr/lib/sysusers.d"
  echo "u libvirtdbus - -" > "${pkgdir}/usr/lib/sysusers.d/libvirtdbus.conf"
}
